<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>simSetThreadSwitchAllowed</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../../index.html" TARGET="_top"><img src="../images/homeImg.png"></a></p>

<h1>Regular API function</h1>
<h3 class=subsectionBar><a name="simSetThreadSwitchAllowed" id="simSetThreadSwitchAllowed"></a>sim.setThreadSwitchAllowed</h3>
<table class=apiTable>
<tr class=apiTableTr> 
<td class=apiTableLeftDescr>
Description 
</td> 
<td class=apiTableRightDescr>Allows to temporarily forbid all thread interruptions, including explicit interruptions or switches. For complete control over thread switching, see also <a href="simGetThreadSwitchAllowed.htm">sim.getThreadSwitchAllowed</a>, <a href="simSetThreadAutomaticSwitch.htm">sim.setThreadAutomaticSwitch</a>, <a href="simSetThreadSwitchTiming.htm">sim.setThreadSwitchTiming</a> and <a href="simSwitchThread.htm">sim.switchThread</a>.</td>
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCSyn>
C synopsis
</td> 
<td class=apiTableRightCSyn><div></div></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCParam>C parameters</td> 
<td class=apiTableRightCParam>
<div></div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCRet>
C return value
</td> 
<td class=apiTableRightCRet>
<div></div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLSyn>
Lua synopsis
</td> 
<td class=apiTableRightLSyn>int switchForbidLevel=sim.setThreadSwitchAllowed(boolean allowSwitch / int forbidLevel)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLParam>Lua parameters</td> 
<td class=apiTableRightLParam>
<div><strong>allowSwitch</strong>: if false, then the thread will not be interrupted anymore (i.e. thread switching will be temporarily disabled). Calling n times sim.setThreadSwitchAllowed(false) requires to call n times sim.setThreadSwitchAllowed(true) to restore the initial behaviour.</div>
<div><strong>forbidLevel</strong>: allows to set a switch forbid level: a level  &gt; 0 indicates that thread interruption is disabled.</div>
<div></div>
<div>Best is to always use following to temporarily forbid thread interruptions:</div>
<pre class=lightRedBoxNoMarginAndSmall>local initialForbidLevel=sim.setThreadSwitchAllowed(false) -- forbid thread switches
...
sim.setThreadSwitchAllowed(initialForbidLevel) -- restore to initial state</pre>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLRet>
Lua return values
</td> 
<td class=apiTableRightLRet>
<div><strong>switchForbidLevel</strong>: the forbid switch level before calling the function, i.e. the forbid switch level that should be restored later on.</div></td> 
</tr> 
</table> 


<br>
</td>
</tr>
</table>
</div>
</body>
</html>
